//
//  EMAppConfig.swift
//  swiftim
//
//  Created by yangjian on 2023/5/30.
//

import Foundation
import HyphenateChat
import UserNotifications

import JFHeroBrowser

class EMAppConfig{
    
    //singleton
    static let share = EMAppConfig()
    private init(){}
    
    //初始化IM客户端
    func configIMClient(appdelegate : AppDelegate){
        
        //初始化IMclient
        let appkey = emAppKey
        let options = EMOptions.init(appkey: appkey)
//        options.enableConsoleLog = true
//        options.isAutoLogin = false
        EMClient.shared().initializeSDK(with: options);
        
        //初始化IMclient的监听者管理器
        RXEMObservableManager.share.config();
        //登录状态以及跳转界面
        EMIMHelper.share.config(appdelegate: appdelegate)
    }
    
    //初始化音视频部分
    func configCallManager(appdelegate : AppDelegate){
        
    }
    
    //注册推送
    func registerUserNotification(appdelegate : AppDelegate) {
        UNUserNotificationCenter.current().delegate = EMUserNotificationHelper.share
        EMLocalNotificationManager.shared().launch(with: EMUserNotificationHelper.share)
        UNUserNotificationCenter.current().requestAuthorization(options: [.badge,.sound,.alert]) { granted, error in
            if granted {
                DispatchQueue.main.async {
                    UIApplication.shared.registerForRemoteNotifications()
                }
            }
        }
    }
    func resetApplicationIconBadgeNumber(number : Int){
        UIApplication.shared.applicationIconBadgeNumber = 0
    }

    //配置bugly
    func configBugly(){
        
    }

    
    //图片选择器需要初始化一下
    func cunfigImageBrowser(){
        JFHeroBrowserGlobalConfig.default.networkImageProvider = HeroNetworkImageProvider.shared
    }
    
    
    
    
}
